<?php

namespace App\Jobs\Plane\PlaneOrder;

use App\Models\Plane\PlaneOrders\PlaneOrder;
use App\Models\Plane\PlaneOrders\PlaneOrderReturnApply;
use App\Trip\Plane\Interfaces\PlaneOrderInterface;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;

class ProcessRefundApply implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    protected int                 $retry = 1;
    private PlaneOrderInterface   $service;
    private PlaneOrder            $order_info;
    private PlaneOrderReturnApply $return_info;
    private array                 $passengers;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct(PlaneOrderInterface $service, PlaneOrder $order_info, PlaneOrderReturnApply $return_info, array $passengers)
    {
        $this->service     = $service;
        $this->order_info  = $order_info;
        $this->return_info = $return_info;
        $this->passengers  = $passengers;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        $this->service->refund_apply($this->order_info, $this->return_info, $this->passengers);
    }
}
